package class06;

/**
 * @Auther: xw
 * @Create: 2022/3/28 9:57
 * @Description: 返回一个树的最大深度  https://leetcode.com/problems/maximum-depth-of-binary-tree
 */
public class MaxDepthOfBinaryTree {
    public static class TreeNode {
        public int val;
        public TreeNode left;
        public TreeNode right;
    }
    // 以root为头的树，最大高度是多少返回！
    public static int maxDepth(TreeNode root) {
        if(null == root){
            return 0;
        }
        return Math.max(maxDepth(root.left),maxDepth(root.right)) + 1;
    }
}
